<?php

namespace App\Admin\Actions;

use App\Model\Order;
use Encore\Admin\Actions\RowAction;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\Request;

class doDeliver extends RowAction
{
    public $name = '订单发货';

    public function handle(Model $model,Request $request)
    {
        // $model ...
//        $deliverCompany = $request->get('deliver_company');
        $deliverCompany = '';
        $deliverSn = $request->get('deliver_sn');

        $orderInfo = Order::query()->where('id',$model->order_id)->first();
        $orderInfo->deliver_company = $deliverCompany;
        $orderInfo->deliver_sn = $deliverSn;
        $orderInfo->order_status = 2;
        $orderInfo->save();

        return $this->response()->success('发货成功')->refresh();
    }

    public function form()
    {

//        $this->text('deliver_company', '快递公司名称');
        $this->text('deliver_sn', '运单号');
    }

}